<script setup lang="ts">

defineProps<{ src?: string, alt?: string }>();

const imgRef = ref<HTMLImageElement>();

onMounted(() => {
    imgRef.value?.addEventListener('error', () => imgRef.value!.src = '/avatar.png');
});

</script>

<template>
    <client-only>
        <img v-bind="$attrs" :src="src || '/avatar.png'" ref="imgRef" />
    </client-only>
</template>